
package com.kugou.game.sdk.receiver;

import com.kugou.game.sdk.service.MessageService;
import com.kugou.game.sdk.utils.AppUtil;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

public class PowerReceiver extends BroadcastReceiver {

    static final String TAG = "PowerReceiver";

    public static final String ACTION_SERVICE_DESTORY = "com.kugou.game.sdk.service.destroy";

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals(Intent.ACTION_BOOT_COMPLETED)
                || action.equals(Intent.ACTION_USER_PRESENT)
                || action.equals(ACTION_SERVICE_DESTORY)
                || action.equals(Intent.ACTION_PACKAGE_ADDED)
                || action.equals(Intent.ACTION_PACKAGE_REMOVED)) {
            String packegename = AppUtil.isServiceRunning(context, MessageService.class);
            if (TextUtils.isEmpty(packegename)) {
                AppUtil.startPushService(context, null, 0, "0");
            }
        }
    }
}
